<link rel="stylesheet" type="text/css" href="/lib/zTree_v3/css/zTreeStyle/zTreeStyle.css">
<script type="text/javascript" src="/lib/zTree_v3/js/jquery.ztree.core.js"></script>
<script type="text/javascript" src="/lib/zTree_v3/js/jquery.ztree.excheck.js"></script>

<!-- 该页面只负责生成初始的数据结构,不包含任何勾选内容 -->
<div class="layui-row layui-col-space10" style="position: relative;overflow: hidden;">
    <div class="layui-inline"  style="height: 440px;width:96%;overflow-y: scroll;overflow-x: scroll;">
        <div id="tree" class="demo-tree-more"></div>
    </div>
    <button class="layui-btn"
            style="position:absolute;top:90%;right:6%;width:80px;height:30px;line-height:10px;border:none;outline:none;background-color:#1E9FFF;color:white;font-size: 17px;"
            onclick="Departmentconfirm()">确认</button>
</div>
<style>
    .layui-layer-content{
        overflow: hidden !important;
    }
</style>
<script>
    //调用tree组件
    idNow = $('#idNow').val();
    shared.ajaxGet('/sys-mgr/getMenuTree', {"role_id":idNow}, function (res) {
        if (res) {
            layui.use('tree',function () {
                var tree = layui.tree;
                tree.render({
                    elem:"#tree",
                    showCheckbox:true,
                    id:"roleTree",
                    data:res,
                    /*click:function (obj) {
                        var data = obj.data;
                        /!*layer.msg('状态：'+ obj.state + '<br>节点数据：' + JSON.stringify(data));*!/
                    }*/
                })
            })
        }
    })

    /*点击确认按钮*/
    function Departmentconfirm(){
        checkedData = layui.tree.getChecked('roleTree');

        /*$('#dataAuthority').val(checkedData);*/
        layer.close(layer.index);
    }
</script>